package com.srwl.mytx.domain;

import android.os.Parcel;
import android.os.Parcelable;

import com.srwl.mytx.domain.User;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Advertisement implements Parcelable {
    private String id;

    private String uId;//用户id

    private String oId;//offerId

    private String rId;//直播间id 也是直播间关联的topicId

    private String dId;//生成的捐赠id

    private String title;

    private Double amount;
    //广告位保证金
    private Double deposit;

    // 广告位投放时间段
    private List<Integer> time;

    private String picture;

    private String video;

    private String forwardTopicId;

    private String forwardUrl;

    private Double donationAmount;

    private String url;

    private Integer offerCount;

    private Integer updateCount;

    private Integer type;

    private Integer status;

    private Date created;

    private Date updated;

    private MyFile myFile;

    private User targetUser;

    private LiveRoom liveRoom;

    public Advertisement(String id, String uId, String oId, String rId, String dId, String title, Double amount, Double deposit, Double donationAmount, List time, String picture, String video, String forwardTopicId, String forwardUrl, Integer offerCount, Integer updateCount, Integer type, Integer status, Date created, Date updated) {
        this.id = id;
        this.uId = uId;
        this.oId = oId;
        this.rId = rId;
        this.dId = dId;
        this.title = title;
        this.amount = amount;
        this.deposit = deposit;
        this.donationAmount = donationAmount;
        this.time = time;
        this.picture = picture;
        this.video = video;
        this.forwardTopicId = forwardTopicId;
        this.forwardUrl = forwardUrl;
        this.offerCount = offerCount;
        this.updateCount = updateCount;
        this.type = type;
        this.status = status;
        this.created = created;
        this.updated = updated;
    }


    public Advertisement() {
        super();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id == null ? null : id.trim();
    }

    public String getuId() {
        return uId;
    }

    public void setuId(String uId) {
        this.uId = uId;
    }

    public String getoId() {
        return oId;
    }

    public void setoId(String oId) {
        this.oId = oId == null ? null : oId.trim();
    }

    public String getrId() {
        return rId;
    }

    public void setrId(String rId) {
        this.rId = rId == null ? null : rId.trim();
    }

    public String getdId() {
        return dId;
    }

    public void setdId(String dId) {
        this.dId = dId == null ? null : dId.trim();
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    public Double getDeposit() {
        return deposit;
    }

    public void setDeposit(Double deposit) {
        this.deposit = deposit;
    }

    public List<Integer> getTime() {
        return time;
    }

    public void setTime(List<Integer> time) {
        this.time = time;
    }

    public String getPicture() {
        return picture;
    }

    public void setPicture(String picture) {
        this.picture = picture;
    }

    public String getVideo() {
        return video;
    }

    public void setVideo(String video) {
        this.video = video;
    }

    public String getForwardTopicId() {
        return forwardTopicId;
    }

    public void setForwardTopicId(String forwardTopicId) {
        this.forwardTopicId = forwardTopicId;
    }

    public String getForwardUrl() {
        return forwardUrl;
    }

    public void setForwardUrl(String forwardUrl) {
        this.forwardUrl = forwardUrl;
    }

    public Double getDonationAmount() {
        return donationAmount;
    }

    public void setDonationAmount(Double donationAmount) {
        this.donationAmount = donationAmount;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url == null ? null : url.trim();
    }

    public Integer getOfferCount() {
        return offerCount;
    }

    public void setOfferCount(Integer offerCount) {
        this.offerCount = offerCount;
    }

    public Integer getUpdateCount() {
        return updateCount;
    }

    public void setUpdateCount(Integer updateCount) {
        this.updateCount = updateCount;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Date getUpdated() {
        return updated;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;
    }

    public MyFile getMyFile() {
        return myFile;
    }

    public void setMyFile(MyFile myFile) {
        this.myFile = myFile;
    }

    public User getTargetUser() {
        return targetUser;
    }

    public void setTargetUser(User targetUser) {
        this.targetUser = targetUser;
    }

    public LiveRoom getLiveRoom() {

        return liveRoom;
    }

    public void setLiveRoom(LiveRoom liveRoom) {
        this.liveRoom = liveRoom;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.id);
        dest.writeString(this.uId);
        dest.writeString(this.oId);
        dest.writeString(this.rId);
        dest.writeString(this.dId);
        dest.writeString(this.title);
        dest.writeValue(this.amount);
        dest.writeValue(this.deposit);
        dest.writeList(this.time);
        dest.writeString(this.picture);
        dest.writeString(this.video);
        dest.writeString(this.forwardTopicId);
        dest.writeString(this.forwardUrl);
        dest.writeValue(this.donationAmount);
        dest.writeString(this.url);
        dest.writeValue(this.offerCount);
        dest.writeValue(this.updateCount);
        dest.writeValue(this.type);
        dest.writeValue(this.status);
        dest.writeLong(this.created != null ? this.created.getTime() : -1);
        dest.writeLong(this.updated != null ? this.updated.getTime() : -1);
        dest.writeParcelable(this.myFile, flags);
        dest.writeParcelable(this.targetUser, flags);
        dest.writeParcelable(this.liveRoom, flags);
    }

    protected Advertisement(Parcel in) {
        this.id = in.readString();
        this.uId = in.readString();
        this.oId = in.readString();
        this.rId = in.readString();
        this.dId = in.readString();
        this.title = in.readString();
        this.amount = (Double) in.readValue(Double.class.getClassLoader());
        this.deposit = (Double) in.readValue(Double.class.getClassLoader());
        this.time = new ArrayList<Integer>();
        in.readList(this.time, Integer.class.getClassLoader());
        this.picture = in.readString();
        this.video = in.readString();
        this.forwardTopicId = in.readString();
        this.forwardUrl = in.readString();
        this.donationAmount = (Double) in.readValue(Double.class.getClassLoader());
        this.url = in.readString();
        this.offerCount = (Integer) in.readValue(Integer.class.getClassLoader());
        this.updateCount = (Integer) in.readValue(Integer.class.getClassLoader());
        this.type = (Integer) in.readValue(Integer.class.getClassLoader());
        this.status = (Integer) in.readValue(Integer.class.getClassLoader());
        long tmpCreated = in.readLong();
        this.created = tmpCreated == -1 ? null : new Date(tmpCreated);
        long tmpUpdated = in.readLong();
        this.updated = tmpUpdated == -1 ? null : new Date(tmpUpdated);
        this.myFile = in.readParcelable(MyFile.class.getClassLoader());
        this.targetUser = in.readParcelable(User.class.getClassLoader());
        this.liveRoom = in.readParcelable(LiveRoom.class.getClassLoader());
    }

    public static final Creator<Advertisement> CREATOR = new Creator<Advertisement>() {
        @Override
        public Advertisement createFromParcel(Parcel source) {
            return new Advertisement(source);
        }

        @Override
        public Advertisement[] newArray(int size) {
            return new Advertisement[size];
        }
    };
}